/*
 * as5600.c
 *
 *  Created on: Dec 28, 2023
 *      Author: 80424
 */

#include "as5600.h"




unsigned char write_reg(unsigned char reg, unsigned char value)
{
	return HAL_I2C_Mem_Write(&AS5600I2C, Slave_Addr, reg, I2C_MEMADD_SIZE_8BIT, &value, 1, 50);
}

unsigned char write_regs(unsigned char reg, unsigned char *value, unsigned char len)
{
	return HAL_I2C_Mem_Write(&AS5600I2C, Slave_Addr, reg, I2C_MEMADD_SIZE_8BIT, value, len, 50);
}

unsigned char read_reg(unsigned char reg, unsigned char* buf, unsigned short len)
{

	return HAL_I2C_Mem_Read(&AS5600I2C, Slave_Addr, reg, I2C_MEMADD_SIZE_8BIT, buf, len, 50);
}



uint16_t i2c_AS5600_get_angle(void)
{

	int16_t in_angle;
    uint8_t temp[2]={0,0};
	read_reg( Angle_Hight_Register_Addr, temp, 2);
    in_angle = ((int16_t)temp[0] <<8) | (temp[1]);
    return in_angle;
}




